﻿<UserControl x:Class="MoneyManagerNET.Presentation.View.AssetListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             
             
              xmlns:vm="clr-namespace:MoneyManagerNET.Presentation.ViewModel;assembly=MoneyManagerNET.Presentation.ViewModel"
             d:DataContext="{x:Static Member=vm:DesignTimeViewModelSupplier.AssetList}"
             
             xmlns:fix="clr-namespace:MoneyManagerNET.Presentation.Infrastructure;assembly=MoneyManagerNET.Presentation.ViewModel">
    <UserControl.Resources>
        

    </UserControl.Resources>
    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Assets" FontSize="13"/>
            <TextBlock Text="   Total:"/>
            <TextBlock Text="{Binding Total,StringFormat=\{0:0.00\}}"/>
        </StackPanel>
        
        <DataGrid AutoGenerateColumns="False" Name="dataGrid1" ItemsSource="{Binding Path=Assets}" Grid.Row="1" SelectedItem="{Binding Selected}">
            <DataGrid.Columns>

                <DataGridTemplateColumn Header="Value">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate />
                    </DataGridTemplateColumn.CellEditingTemplate>
                    <DataGridTemplateColumn.CellTemplate>

                        <DataTemplate >
                            <TextBlock  >
                                <TextBlock.Text>
                                    <Binding>
                                        <Binding.Converter>
                                            <fix:CurrentAssetValueConverter  />
                                        </Binding.Converter>
                                    </Binding>
                                </TextBlock.Text>
                            </TextBlock>

                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding Path=AssetType}" Header="Type" />
                <DataGridTextColumn Binding="{Binding Path=Date,StringFormat=\{0:d\}}" Header="Date" />
                <DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" />
            </DataGrid.Columns>
            
        </DataGrid>


        <StackPanel Grid.Row="2" Orientation="Horizontal">
            <Button  Command="{Binding NewCommand}" IsEnabled="{Binding CanCreateNew}">
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Green}"/>
                </Button.Foreground> New
            </Button>
            <Button  Command="{Binding EditCommand}">
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Edit}"/>
                </Button.Foreground> Edit
            </Button>
            <Button Command="{Binding DeleteCommand}">
                <Button.Foreground>
                    <SolidColorBrush Color="{DynamicResource Red}"/>
                </Button.Foreground> Delete
            </Button>
            <Label Content="{Binding ChangeText}"/>
        </StackPanel>
        
        <Label Content="{Binding Notes}"></Label>
    </Grid>
</UserControl>
